package com.example.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 实现 WebMvcConfigurer.addInterceptors（）方法
 * addInterceptor：需要一个实现HandlerInterceptor接口的拦截器实例
 * addPathPatterns：用于设置拦截器的过滤路径规则
 * excludePathPatterns：用于设置不需要拦截的过滤规则
 *
 * @author kangshuai
 */
@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new RequestInterceptor()).addPathPatterns("/**").excludePathPatterns("/login/**", "/error");
    }

}
